﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __0BBCA93C_641A_4485_B668_429C7F0A4EBE__
#define __0BBCA93C_641A_4485_B668_429C7F0A4EBE__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_aio
{
    class aio_worker;
    class aio_key;
    class aio_impl;

    class aio_thread
    {
    public:
        aio_thread( aio_impl * pAioImpl );
        ~aio_thread();

    protected:
        static void * thread( void * lpData );
        int helper_run( epoll_event & e );
        int run( int nNum );

        int proc_epoll_event( epoll_event & e );
        int proc_user_request();
        
    public:
        bool m_bQuit;

    protected:
        struct epoll_event m_event[1024];
        aio_impl * m_pAioImpl;
        xos::i_thread * m_pThread;

    public:
        int init();
        int term();
    };
} // xos_aio

#endif // __0BBCA93C_641A_4485_B668_429C7F0A4EBE__
